<template>
    <div>
        <div class="card card-custom gutter-b example example-compact" id="tableBody">
            <div class="card-header">
                <div class="card-title">
                    <span class="card-icon">
                        <i class="text-dark-50 flaticon-search-magnifier-interface-symbol"></i>
                    </span>
                    <h3 class="card-label"> 查询区域 </h3>
                </div>
                <div class="card-toolbar">
                    <div class="example-tools justify-content-center">
                    </div>
                </div>
            </div>
            <div class="card-body">
                <!--查询条件-->
                <div class="m-form m-form--fit m-form--label-align-left m-form--group-seperator-dashed">
                    <div class="m-portlet__body">
                        <div class="form-group m-form__group row">
                            <label class="col-form-label">视频名称：</label>
                            <div class="col-lg-2">
                                <input type="text" class="form-control" v-model="searchForm.name" placeholder="请输入">
                            </div>
                            <label class="col-form-label">视频编码：</label>
                            <div class="col-lg-2">
                                <input type="text" class="form-control" v-model="searchForm.code" placeholder="请输入">
                            </div>
                            <label class="col-form-label">生产商：</label>
                            <div class="col-lg-2">
                                <el-select v-model="searchForm.oemId" placeholder="请选择">
                                    <el-option
                                    v-for="item in oemList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                                    </el-option>
                                </el-select>
                            </div>
                            <b-button :pressed="false" variant="btn btn-primary font-weight-bold mr-2"
                                @click="search()"><span><i class="fa fa-search"></i><span>查询</span></span></b-button>
                            <b-button :pressed="false" variant="btn btn-light font-weight-bold mr-2" @click="resetAll()">
                                <span><span>清空条件</span></span></b-button>
                        </div>
                    </div>
                    <div class="m-portlet__foot m-portlet__no-border m-portlet__foot--fit">
                        <div class="m-form__actions m-form__actions--solid">
                            <div class="row">
                                <div class="col m--align-left">

                                </div>
                                <div class="col m--align-right">

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--分页组件-->
            <el-table style="width: 100%" stripe border @selection-change="handleSelectionChange" highlight-current-row
                :data="dataList">
                <!-- 复选框 -->
                <el-table-column type="selection" width="40"></el-table-column>
                <el-table-column label="序号" min-width="50">
                    <template slot-scope="scope">
                        {{ scope.$index + 1 }}
                    </template>
                </el-table-column>
                <el-table-column align="left" prop="deviceTypeName" show-overflow-tooltip label="视频类型" min-width="150"></el-table-column>
                <el-table-column align="left" prop="code" show-overflow-tooltip label="视频编码" min-width="150"></el-table-column>
                <el-table-column align="left" prop="name" show-overflow-tooltip label="视频名称" min-width="150"></el-table-column>
                <el-table-column align="left" prop="shortName" show-overflow-tooltip label="简称" min-width="150"></el-table-column>
                <el-table-column align="left" prop="oemName" show-overflow-tooltip label="生产商" min-width="150"></el-table-column>
                <el-table-column align="center" prop="createBy" label="创建人" min-width="150"></el-table-column>
                <el-table-column align="center" prop="createTime" label="创建时间" min-width="180"></el-table-column>
                <el-table-column align="center" prop="modifiedBy" label="修改人" min-width="150"></el-table-column>
                <el-table-column align="center" prop="updateTime" label="修改时间" min-width="180"></el-table-column>
                <el-table-column align="center" label="操作" fixed="right">
                    <template slot-scope="scope">
                        <!--scope.row当前行的对象-->
                        <a href="javascript:;" @click="playWin(scope.row)" class="btn btn-sm btn-clean btn-icon"
                            title="播放">
                            <span class="svg-icon svg-icon-primary svg-icon-2x">
                                <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
                                    <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                                        <rect x="0" y="0" width="24" height="24"/>
                                        <rect fill="#000000" x="2" y="6" width="13" height="12" rx="2"/>
                                        <path d="M22,8.4142119 L22,15.5857848 C22,16.1380695 21.5522847,16.5857848 21,
                                        16.5857848 C20.7347833,16.5857848 20.4804293,16.4804278 20.2928929,16.2928912 L16.7071064,
                                        12.7071013 C16.3165823,12.3165768 16.3165826,11.6834118 16.7071071,11.2928877 L20.2928936,
                                        7.70710477 C20.683418,7.31658067 21.316583,7.31658098 21.7071071,7.70710546 C21.8946433,
                                        7.89464181 22,8.14899558 22,8.4142119 Z" fill="#000000" opacity="0.3"/>
                                    </g>
                                </svg>
                            </span>
                        </a>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block">
                <el-pagination hide-on-single-page @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="pageNo" :page-sizes="[5, 10, 30, 50]" :page-size="pageSize"
                    layout="->,total, sizes, prev, pager, next, jumper" :total="totalCount">
                </el-pagination>
            </div>
        </div>
        <VideoFlvPlay ref="VideoFlvPlayRef"></VideoFlvPlay>
        <VideoHlsPlay ref="VideoHlsPlayRef"></VideoHlsPlay>
        <VideoJSPlay ref="VideoJSPlayRef"></VideoJSPlay>        
    </div>
</template>
  
<script>
import { SET_BREADCRUMB } from "@/store/breadcrumbs.module";
import VideoFlvPlay from "@/view/monitor/iot-video/flv-win.vue";
import VideoHlsPlay from "@/view/monitor/iot-video/hls-win.vue";
import VideoJSPlay from "@/view/monitor/iot-video/videojs-win.vue";
import Swal from "sweetalert2";
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            oemList:[],
            searchForm: { name: "", code: "", oemId: "" },
            dataList: [],
            sels: [], //当前选框选中的值
            pageNo: 1,      // 默认当前是第一页
            pageSize: 5,    // 当前每页的数据是5条
            totalCount: 0   // 总数默认为0
        }
    },
    components: {
        VideoFlvPlay,
        VideoHlsPlay,
        VideoJSPlay,
    },
    mounted() {
        this.$store.dispatch(SET_BREADCRUMB, [{ title: "视频监控" }]);
        this.initList();   // 按当前的页号和每页的数据量进行查询
        this.initOEMList();
    },
    methods: {
        initList() {
            showWating({ renderBody: "tableBody" });
            var params = {};
            params.usePageNo = true;//采用第几页进行分页（兼容）
            params.pageSize = this.pageSize;//页面显示记录条数，在页面显示每页显示多少项的时候
            params.pageNo = this.pageNo;//开始的记录序号   
            params.searchJson = JSON.stringify(this.searchForm);//为form元素     
            apiUtil.queryPage(process.env.VUE_APP_MONITOR_API + "/iotVideo/list", params).then(({ data }) => {
                this.dataList = data.data;//给结果集赋值
                this.totalCount = data.total;// 获取当前数据的总数    
            });
        },
        handleSelectionChange(sels) {//获取选中的值
            this.sels = sels;
        },        
        handleSizeChange(val) { // 修改每页所存数据量的值所触发的函数
            this.pageSize = val;  // 修改页的大小
            this.initList();       // 按新的pageNo和pageSize进行查询
        },
        handleCurrentChange(val) { // 修改当前页所触发的函数
            this.pageNo = val;       // 更新当前的页
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        search() {
            this.pageNo = 1;       // 更新当前的页
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        resetAll() {
            Object.assign(this.$data.searchForm, this.$options.data().searchForm);
            this.search();
        },
        playWin(row) {
            this.$refs.VideoFlvPlayRef.showModal(row);//flv播放器
            // this.$refs.VideoHlsPlayRef.showModal(row);//hls播放器
            // this.$refs.VideoJSPlayRef.showModal(row);//videojs播放器            
        },
        initOEMList(){
            let params = {};
            apiUtil.query(process.env.VUE_APP_MONITOR_API+"/iotOem/allList", params).then(({ data }) => {
                this.oemList = data.data;
            });
        }
    }
};
</script>